package cn.lfzj.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.lfzj.model.BusLine;

public interface BusLineDao {
	
	/**
	 * 查询全部线路
	 */
	@Select("SELECT * FROM bus_line order by line_name")
	public List<BusLine> findAll();

	/**
	 * 新增线路
	 */
	@Insert("INSERT INTO bus_line(line_name,start_station,end_station,ticket_price) "
			+ "VALUES(#{lineName},#{startStation},#{endStation},#{ticketPrice})")
	public int addBusLine(BusLine busLine);

	/**
	 * 删除线路
	 */
	@Delete("DELETE FROM bus_line WHERE line_id=#{lineId}")
	public int delBusLine(int lineId);

	/**
	 * 修改线路
	 */
	@Update("UPDATE bus_line "
			+ "SET line_name=#{lineName},start_station=#{startStation},end_station=#{endStation},ticket_price=#{ticketPrice} "
			+ "WHERE line_id=#{lineId}")
	public int updBusLine(BusLine busLine);

	/**
	 * 根据ID查线路
	 */
	@Select("SELECT * FROM bus_line WHERE line_id=#{lineId}")
	public BusLine selById(int lineId);

	/**
	 * 线路是否存在
	 */
	@Select("SELECT * FROM bus_line "
			+ "WHERE line_name=#{lineName} and start_station=#{startStation} and end_station=#{endStation} and ticket_price=#{ticketPrice}")
	public BusLine find(BusLine busLine);
}
